package com.prj.ufdm.cloud.ms.core.enums;

/**
 * 变更日志枚举类
 * @author: zhujq
 * @date: 2019/9/11 10:53
 */
public enum LogChangeLevelEnum {
    /**
     * dao所有变更日志，包括INSERT\UPDATE\DELETE三种类型
     */
    ALL("1", "ALL"),
    /**
     * dao的INSERT变更日志
     */
    INSERT("2", "INSERT"),
    /**
     * dao的UPDATE变更日志
     */
    UPDATE("3", "UPDATE"),
    /**
     * dao的DELETE变更日志
     */
    DELETE("4", "DELETE"),
    /**
     * 不记录N
     */
    NO_LOG("5", "NO");

    public static String getLabelByCode(int code){
        String label = "";
        for (LogChangeLevelEnum logChangeLevelEnum : LogChangeLevelEnum.values()) {
            if(logChangeLevelEnum.code.equals(code)){
                label = logChangeLevelEnum.label;
            }
        }
        return label;
    }

    public static String getCodeBylabel(String label){
        String code = null;
        for (LogChangeLevelEnum logChangeLevelEnum : LogChangeLevelEnum.values()) {
            if(logChangeLevelEnum.label.equalsIgnoreCase(label)){
                code = logChangeLevelEnum.code;
            }
        }
        return code;
    }

    private String code;

    private String label;

    LogChangeLevelEnum(String code, String label) {
        this.code = code;
        this.label = label;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }
}
